<!-- Easy Login module HEADER -->
<style >
#fancybox-content{
	{if $ZBORDER_COLOR}
		border-color: {$ZBORDER_COLOR};	
	{/if}
	{if $ZBACKGROUND_COLOR}
		background-color: {$ZBACKGROUND_COLOR};
	{/if}
}
</style>
<script type="text/javascript">
//<![CDATA[
	$(document).ready(function(){ldelim}
		var txtThereis = "{l s='There is'}";
		var txtErrors = "{l s='error(s)'}";
		// SETTING FANCYBOX FORM LOGIN
		var urlinfo = $("#header_user_info a").attr("href");
		if( urlinfo.indexOf( "my-account" ) !== -1 )
		{
			$('#header_user_info a').click(function() {
				$("#zeasy_login_errors").hide();
			});
			$('#header_user_info a').fancybox({
				'transitionIn' : '{$ZTRANSITION_IN}', 	// 'elastic', 'fade' or 'none'
				'transitionOut' : '{$ZTRANSITION_OUT}',	// 'elastic', 'fade' or 'none'
				'speedIn' : {$ZSPEED_IN},
				'speedOut' : {$ZSPEED_OUT},
				hideOnOverlayClick : {$ZOVERLAY_CLICK},
				showCloseButton	 : {$ZCLOSE_BUTTON},
				overlayColor : '{$ZOVERLAY_COLOR}',
				width : 1000,
			}); 
		}

		$('#zforgot-password').click(function() {
			$("#zretrieve_password_confirm").hide();
		});
		// SETTING FANCYBOX FORM FORGOT PASSWORD
		$('#zforgot-password').fancybox({
			'transitionIn' : '{$ZTRANSITION_IN}', 	// 'elastic', 'fade' or 'none'
			'transitionOut' : '{$ZTRANSITION_OUT}',	// 'elastic', 'fade' or 'none'
			'speedIn' : {$ZSPEED_IN},
			'speedOut' : {$ZSPEED_OUT},
			hideOnOverlayClick : {$ZOVERLAY_CLICK},
			showCloseButton	 : {$ZCLOSE_BUTTON},
			overlayColor : '{$ZOVERLAY_COLOR}'
		}); 

		
		// SETTING FANCYBOX FORM CREAT ACCOUNT
		$('#zcreat-account').fancybox({
			'transitionIn' : '{$ZTRANSITION_IN}', 	// 'elastic', 'fade' or 'none'
			'transitionOut' : '{$ZTRANSITION_OUT}',	// 'elastic', 'fade' or 'none'
			'speedIn' : {$ZSPEED_IN},
			'speedOut' : {$ZSPEED_OUT},
			hideOnOverlayClick : {$ZOVERLAY_CLICK},
			showCloseButton	 : {$ZCLOSE_BUTTON},
			overlayColor : '{$ZOVERLAY_COLOR}'
		}); 
		 
		// LOGIN FORM SENDING
		$('#SubmitLogin').click(function() {
			$("#fancybox-loading").show();
			$.ajax({
				type: 'POST',
				url: baseDir + 'authentication.php',
				async: false,
				cache: false,
				dataType : "json",
				data: 'SubmitLogin=true&ajax=true&email='+encodeURIComponent($('#login_email').val())+'&passwd='+encodeURIComponent($('#login_passwd').val())+'&token=' + static_token ,
				success: function(jsonData)
				{
					var currentI = ($('#zlogin_form #zcurrentIndex').val());
					if (jsonData.hasError)
					{
						var errors = '<b>'+txtThereis+' '+jsonData.errors.length+' '+txtErrors+':</b><ol>';
						for(error in jsonData.errors)
							//IE6 bug fix
							if(error != 'indexOf')
								errors += '<li>'+jsonData.errors[error]+'</li>';
						errors += '</ol>';
						$('#zeasy_login_errors').html(errors).slideDown('slow');
					}
					else
					{
						// update token
						static_token = jsonData.token;
						$.fancybox.close();
						window.location.href = currentI;
					}
					$("#fancybox-loading").hide();
				},
			});
			return false;
		});

		// Retrieve Password FORM SENDING
		$('#submit-password').click(function() {
			$("#fancybox-loading").show();
			$.ajax({
				type: 'POST',
				url: baseDir + 'modules/zeasylogin/password.php',
				async: false,
				cache: false,
				dataType : "json",
				data: 'SubmitPassword=true&ajax=true&email='+encodeURIComponent($('#emailpassword').val())+'&token=' + static_token ,
				success: function(jsonData)
				{
					var currentI = ($('#zlogin_form #zcurrentIndex').val());
					if (jsonData.hasError)
					{
						var errors = '<b>'+txtThereis+' '+jsonData.errors.length+' '+txtErrors+':</b><ol>';
						for(error in jsonData.errors)
							//IE6 bug fix
							if(error != 'indexOf')
								errors += '<li>'+jsonData.errors[error]+'</li>';
						errors += '</ol>';
						$('#zretrieve_password_confirm').removeClass();
						$('#zretrieve_password_confirm').addClass('error');
						$('#zretrieve_password_confirm').html(errors).slideDown('slow');
					}
					else
					{
						// update token
						static_token = jsonData.token;
						$('#zretrieve_password_confirm').removeClass();
						$('#zretrieve_password_confirm').addClass('success');
						$('#zretrieve_password_confirm').html('{l s="A confirmation e-mail has been sent to your address:"}'+jsonData.email).slideDown('slow');
					}
					$("#fancybox-loading").hide();
				},
			});
			return false;
		});

		// CREAT EMAIL
		$('#zcreat-account').click(function() {
			$("#zcreat_account_error").hide();
		});
		// validate email register
		 $('#SubmitCreate').click(function() {  
	        $("#zcreat_account_error").hide();
	        var hasError = false;
	        var emailaddressVal = $("#email_create").val();
	        var errors1 = '<b>'+txtThereis+' 1 '+txtErrors+':</b><ol><li>{l s="Please enter your email address."}</li></ol>';
	        var errors2 = '<b>'+txtThereis+' 1 '+txtErrors+':</b><ol><li>{l s="Invalid e-mail address."}</li></ol>';
			
	        if(emailaddressVal == '') {
	        	$('#zcreat_account_error').html(errors1).slideDown('slow');
	            hasError = true;
	        }
	        else if(!zemailReg.test(emailaddressVal)) {
	            $("#zcreat_account_error").html(errors2).slideDown('slow');
	            hasError = true;
	        }
	 
	        if(hasError == true) { return false; }

	        $("#fancybox-loading").show();
	        // ajax submit creat account
	        $.ajax({
	        	
				type: 'POST',
				url: baseDir + 'modules/zeasylogin/zcreatemail.php',
				async: false,
				cache: false,
				dataType : "json",
				data: 'SubmitCreate=true&ajax=true&email='+encodeURIComponent(emailaddressVal)+'&token=' + static_token ,
				success: function(jsonData)
				{
					if (jsonData.hasError)
					{
						var errors = '<b>'+txtThereis+' '+jsonData.errors.length+' '+txtErrors+':</b><ol>';
						for(error in jsonData.errors)
							//IE6 bug fix
							if(error != 'indexOf')
								errors += '<li>'+jsonData.errors[error]+'</li>';
						errors += '</ol>';
						$('#zcreat_account_error').html(errors).slideDown('slow');
						hasError = true;
					}
					$("#fancybox-loading").hide();
				},
			});
	        if(hasError == true) { return false; }
	    });
		
	{rdelim});
//]]>
</script>
<div id="frm-hidden">
<!-- Form login -->
	<div  id="frm-login-dialog" class="frm-login-dialog">
		<form action="{$link->getPageLink('authentication.php', true)}" method="post" id="zlogin_form" class="zlogin_form">
			<h3>{l s='Already registered ?'}</h3>
			<hr class="clear" style="margin-bottom: 15px; color: {if $ZLINE_COLOR} {$ZLINE_COLOR} {else} black {/if};" />
			<!-- Error return block -->
			<div id="zeasy_login_errors" class="error" style="display:none;"></div>
			<!-- END Error return block -->
			<input type="hidden" name="zcurrentIndex" id="zcurrentIndex" value="{$link->getPaginationLink(false, false, false, false, true, false)}" />
			
			<label for="login_email">{l s='E-mail address'}</label>
			<div class="margin-form">
				<input type="text" id="login_email" name="email" size="20" />
			</div>
			<div class="clear"></div>
			<label for="passwd">{l s='Password'}</label>
			<div class="margin-form">
				<input type="password" id="login_passwd" name="passwd" size="20" />
			</div>
			<p class="submit">
				{if isset($back)}<input type="hidden" class="hidden" name="back" value="{$back|escape:'htmlall':'UTF-8'}" />{/if}
				<input type="submit" id="SubmitLogin" name="SubmitLogin" class="button" value="{l s='Log in'}" />
			</p>
			<div style="margin: 0px 10px 1px 50px; padding-bottom: 5px;">
				<p style="float:left;"><a id="zcreat-account" href="#frm-creat-account">{l s='Create your account'}</a></p>
				<p class="lost_password" style="float:right;"><a id="zforgot-password" href="#frm-forgot-password">{l s='Forgot your password?'}</a></p>
			</div>
		</form>
	</div>
<!-- Form creat account -->
	<div id="frm-creat-account" class="frm-login-dialog">
		<form action="{$link->getPageLink('authentication.php', true)}" method="post" id="zcreate-account_form" class="zcreat-account_form">
			<h3>{l s='Create your account'}</h3>
			<hr class="clear" style="margin-bottom: 15px; color: {if $ZLINE_COLOR} {$ZLINE_COLOR} {else} black {/if};" />
			<p class="error" id="zcreat_account_error" style="display:none" ></p>
			<p style="margin-bottom: 10px;">{l s='Enter your e-mail address to create an account'}.</p>
			<label for="email_create">{l s='E-mail address'}</label>
			<div class="margin-form">
				<input type="text" id="email_create" name="email_create" value="{if isset($smarty.post.email_create)}{$smarty.post.email_create|escape:'htmlall':'UTF-8'|stripslashes}{/if}" size="28"/>
			</div>
			<p class="submit">
			{if isset($back)}<input type="hidden" class="hidden" name="back" value="{$back|escape:'htmlall':'UTF-8'}" />{/if}
				<input type="submit" id="SubmitCreate" name="SubmitCreate" class="button_large" value="{l s='Create your account'}" />
				<!-- input type="hidden" class="hidden" name="SubmitCreate" value="{l s='Create your account'}" / -->
			</p>
		</form>
	</div>
<!-- Form forgot password -->	
	<div  id="frm-forgot-password" class="frm-forgot-password" >
		<p>{l s='Please enter the e-mail address used to register. We will e-mail you your new password.'}</p>
		<br />
		<form action="{$link->getPageLink('password.php')}" method="post" class="std">
				<!-- Confirm return block -->
				<div id="zretrieve_password_confirm" style="display:none;"></div>
				<!-- END Confirm return block -->
				<label for="email">{l s='E-mail:'}</label>
				<div class="margin-form">
					<input size="25" type="text" id="emailpassword" name="email" value="{if isset($smarty.post.email)}{$smarty.post.email|escape:'htmlall':'UTF-8'|stripslashes}{/if}" />
				</div>
				<p class="submit">
					<input type="submit" id="submit-password" class="button" value="{l s='Retrieve Password'}" />
				</p>
		</form>
	</div>
</div>

<!-- /Easy Login module HEADER -->